home *** CD-ROM | disk | FTP | other *** search
- Subject: Subtlety with FW_OStorageUnitSink and ODStorageUnit
- Sent: 7/21/96 1:18 AM
- Received: 7/22/96 10:48 AM
- From: Hutchings, Richard B. "Brad", brad@hutchings-software.com
- Reply-To: ODF Interest, ODF-Interest@CILabs.ORG
- To: OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
-
- Following is a subtlety I ran into this evening dealing with
- FW_OStorageUnitSink and ODStorageUnit. Here's a working snippet.
-
- void CyberItemAction::ExternalizeToStream(
- Environment* ev,
- FW_CWritableStream& stream )
- {
- FW_OStorageUnitSink* sink =
- (FW_OStorageUnitSink*) stream.GetSink();
- ODStorageUnitView* view = sink->GetStorageUnitView(ev);
- ODStorageUnit* storage = view->GetStorageUnit(ev);
-
- fCyberItem->StreamToStorageUnit(ev, storage);
-
- ODULong offset = storage->GetOffset(ev);
- sink->SetPosition(ev, offset);
-
- stream << ...
- }
- First, I had to convert to the storage unit because that's what Cyberdog
- expects in CyberItem::StreamToStorageUnit.
-
- Second, notice that when you write directly to the storage unit, the stream
- gets out of date, and that you have to set its position.
-
- Third, notice that I don't use a FW_PStorageUnitSink because it would
- clobber the stream when ~FW_PStorageUnitSink is called on exit.
-
- This could be helped by a "smarter" FW_PStorageUnitSink that had an
- "operator ODStorageUnit*" method which would set a flag in the
- FW_OStorageUnitSink telling it to update its position the next time it's
- accessed from a stream.
-
- Brad
-
- <mailto: "Brad Hutchings" brad@hutchings-software.com>
- <http://www.hutchings-software.com>
-
- Ask me about:
- Hutchings Software's Rapid-I(tm) Button
- Hutchings Software's Essential Strips(tm)
-
-
-